<?php
/**
 * Created by PhpStorm.
 * User: bxm
 * Date: 2022/6/15
 * Time: 21:47
 */

namespace app\api\controller\common;


use app\api\controller\Base;
use app\common\model\base\DictItemModel;
use app\common\model\RoleAuthModel;
use app\common\model\worker\RecommendCateModel;
use think\Request;
use traits\controller\JumpTraits;
class CommonController extends Base
    //extends Base
{
    use JumpTraits;
    /**
     * 构造方法
     * @access public
     * @throws \Exception
     */
    public function __construct()
    {

        parent::__construct();
        $this->checkLogin();

    }
    /**
     * 房屋性质
     * @author bxm
     * @date 2022-06-15 22:01
     */
    public function getHouseAttrList(){
        $list = houseAttrList();
        $this->result($list);
    }

    /**
     * 房屋结构
     * @author bxm
     * @date 2022-06-15 22:01
     */
    public function getHouseStructureList(){
        $list = houseStructureList();
        $this->result($list);
    }

    /**
     * 汇款周期
     * @author bxm
     * @date 2022-06-15 22:01
     */
    public function getPaybackPeriodlist(){
        $list = paybackPeriodlist();
        $this->result($list);
    }
    /**
     * 家装进度
     * @author bxm
     * @date 2022-06-15 21:59
     */
    public function getDecorateProgressList(){
        $list = decorateProgressList();
        $this->result($list);
    }

    /**
     * 推荐人分类
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @author bxm
     * @date 2022-06-17 16:07
     */
    public function getRecommendCatelist(){
        $res = new RecommendCateModel();
        $list = $res->where('status',1)->select();
        $this->result($list);
    }

    /**
     * 见面方式
     * @author bxm
     * @date 2022-06-17 16:16
     */
    public function getFollowList(){
        $list = followList();
        $this->result($list);
    }

    /**
     * @author bxm
     * @date 2022-06-21 15:16
     */
    public function paymentList(){
        $DictItemModel = new DictItemModel();
        $list = $DictItemModel->where('class_code','10.04')->order('show_order','asc')
            ->field('dict_code as id,dict_value as text')->select();
        $this->result($list);
    }
    public function decorateStyleList(){
        $list = decorateStyleList();
        $this->result($list);
    }
    //
    public function getRoleAuthList(Request $request)
    {
        //$param = $request->param();
        $type_id      = $this->request->param('type/d', '');
        $where = [];
        $where[] = ['status', '=', 1];
        if($type_id) $where[] = ['type_id', '=', $type_id];
        $list = RoleAuthModel::where($where)->select()->toArray();
        $this->result($list);
    }

}